Repository navigation
Ocarina of Time: a RomFS .zs file that is not a zstd stream is served as a profile-named substitute, ending a background reload loop (CPU 412% → 180% on the Mac) - #1530
Conversation
…# the true hit count (rates of a loop's branches without a line per hit)
…ofile's romfs_substitute, else "not found"; Ocarina of Time's three damaged textures substituted
The Ocarina of Time NUP at hand holds Tex/CmnTex_Map_Soil_FairyFountain_Floor_D_Nrm.bntx.zs, Tex/Rock_WaterTemple_Gate_M_01_Nrm.bntx.zs and Tex/RBake_Scene_GanonStage_G_2_1_d0_t0.bntx.zs with their first 12 KB zeroed (the container's SHA-256 of them matches, so they were so when it was packed; whether a retail copy has them is not known). The first kept the Kokiri Forest fairy fountain model from loading, so the OptimizeChangeBanc thread (main+0xf7a0, priority 55) never finished its pass over the area's 852 entries and asked for the model again ~22 times a second for the whole session: ~980 ms/s of CPU on the Mac and the iPad, plus ~750 ms/s of ParallelDecompThread decompressing the 2.4 MB model each time.
hle_fs.c img_serve checks a .zs image file's first 4 bytes once (open and entry type). A damaged one is served as the substitute the new profile key romfs_substitute names (DM_ROMFS_SUBST overrides; DM_ROMFS_ZSTD_CHECK=0 serves it as stored), else answered "not found" ("not found" alone still fails the model). Ocarina of Time's profile serves the two normal maps as the game's own 1x1 flat normal and the Ganon stage bake as its neighbour cell's.
Mac, 5-minute runs in Kokiri Forest, windows from frame 5000: CPU 412% -> 180%, OptimizeChangeBanc and ParallelDecompThread out of the top five (idle after frame ~3900), frame p50 17.7 -> 17.3 ms, p95 21.9 -> 18.8, submit CPU 8.9 -> 5.7 ms a frame. Test: t_fs (148 checks). Documented in docs/reference/packing.md (symptom index regenerated).
…# the true hit count (rates of a loop's branches without a line per hit) (from PR #1530) Co-authored-by: aksmith-git <242086076+aksmith-git@users.noreply.github.com>
…ge's .zs files must start with a zstd frame, as an NSP's files must pass the NCA's hashes; a contributor's Ocarina of Time NUP held three .zs textures beginning with zeros, which its background loader reloaded for ever (412% CPU, PR #1530) - romfs_image.format_mismatches reads the first bytes of each file whose name promises a format (FORMAT_HEADS: .zs, a zstd frame or a skippable frame), in image order, no further than the file's own bytes; empty files are left out. - The NSP script's check_formats runs after extraction for NSPs, NUPs and dumps, stops naming the files (pack again from a good copy), and lists them and goes on with --allow-damaged. The result stays in RomFS.img.formats beside the image until the image changes (Ocarina of Time: 102,185 .zs files, 16 s cold from a USB SSD; none damaged in this repository's copy). - In place of PR #1530's run-time substitution, which served other textures for the damaged ones: the host serves a game's files as they are. - Reference entry in packing.md, symptom index, Ocarina of Time note. Unit test; check_formats run on Ocarina of Time's image and on a synthetic damaged one. No game run.
|
Thanks for the careful measurements: they found something real, but in the game files rather than the game. Our NUP of the same version (v131072) has all three files as zstd streams ( What landed instead:
The host keeps serving a game's files as they are: substituting other textures would hide the damage (and change what the game draws), so the host substitution and the profile rows aren't taken. Please repack from a good dump; with that, the loader should go idle as in your after-run, without any substitution. |
|
Another data point on the damage source. A second NUP of v131072, made independently by a different person, has the same three files damaged in the same way. 6bbdbbe's check names exactly these:
Each starts with zeros. Two unrelated copies with identical damage points at the dumping or packing tool, not a bad read. So more NUPs in circulation probably carry it. With this PR's substitutes the host logged the swap for two of them in Kokiri Forest. I didn't measure CPU in that session. — Claude, Santi's agent |
|
Thanks for the second NUP. The reporter of #1605 also had |
…mg), which the packers still take; test_xcode_workflow's fixtures stopped on FileNotFoundError since upstream's format check (seedds#1530) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qteK3qWJVi2jG3Gz4i1eY
…ixes (chain 844bf1a5ea8f, exactly upstream's), raw pool table words at commit (seedds#1427), incremental pool tables (seedds#1489), ocarina input stream (seedds#1527), damaged .zs check (seedds#1530) Conflicts: chain tools and shader_split.py taken from upstream (dmsh_depth.py dropped: upstream compiles the 259-bracket shaders its own way); the build script keeps shader.noindex and takes upstream's progress watch; docs keep both packing entries.
…# the true hit count (rates of a loop's branches without a line per hit) (from PR seedds#1530)
…textures The NSP script's check stopped a player's build on the same three .zs files as the contributor's NUP (PR seedds#1530), two with 12,288 leading zero bytes and the Water Temple gate with 8,192: one damaged release in circulation, it seems, rather than one bad download. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ofile's romfs_substitute, else "not found"; Ocarina of Time's three damaged textures substituted
The Ocarina of Time NUP at hand holds Tex/CmnTex_Map_Soil_FairyFountain_Floor_D_Nrm.bntx.zs, Tex/Rock_WaterTemple_Gate_M_01_Nrm.bntx.zs and Tex/RBake_Scene_GanonStage_G_2_1_d0_t0.bntx.zs with their first 12 KB zeroed (the container's SHA-256 of them matches, so they were so when it was packed; whether a retail copy has them is not known). The first kept the Kokiri Forest fairy fountain model from loading, so the OptimizeChangeBanc thread (main+0xf7a0, priority 55) never finished its pass over the area's 852 entries and asked for the model again ~22 times a second for the whole session: ~980 ms/s of CPU on the Mac and the iPad, plus ~750 ms/s of ParallelDecompThread decompressing the 2.4 MB model each time.
hle_fs.c img_serve checks a .zs image file's first 4 bytes once (open and entry type). A damaged one is served as the substitute the new profile key romfs_substitute names (DM_ROMFS_SUBST overrides; DM_ROMFS_ZSTD_CHECK=0 serves it as stored), else answered "not found" ("not found" alone still fails the model). Ocarina of Time's profile serves the two normal maps as the game's own 1x1 flat normal and the Ganon stage bake as its neighbour cell's.
Mac, 5-minute runs in Kokiri Forest, windows from frame 5000: CPU 412% -> 180%, OptimizeChangeBanc and ParallelDecompThread out of the top five (idle after frame ~3900), frame p50 17.7 -> 17.3 ms, p95 21.9 -> 18.8, submit CPU 8.9 -> 5.7 ms a frame. Test: t_fs (148 checks). Documented in docs/reference/packing.md (symptom index regenerated).
Ported from seedds#1530 (closed upstream, which keeps serving damaged files as they are and stops the build instead, 6bbdbbe) for this fork: the NUP these builds are packed from has the same three files zeroed (RomFS.img.formats), as two other v131072 NUPs do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U35V38c6UYLbzyyPx6Up7P
…# the true hit count (rates of a loop's branches without a line per hit) (from PR seedds#1530) Co-authored-by: aksmith-git <242086076+aksmith-git@users.noreply.github.com>
…ge's .zs files must start with a zstd frame, as an NSP's files must pass the NCA's hashes; a contributor's Ocarina of Time NUP held three .zs textures beginning with zeros, which its background loader reloaded for ever (412% CPU, PR seedds#1530) - romfs_image.format_mismatches reads the first bytes of each file whose name promises a format (FORMAT_HEADS: .zs, a zstd frame or a skippable frame), in image order, no further than the file's own bytes; empty files are left out. - The NSP script's check_formats runs after extraction for NSPs, NUPs and dumps, stops naming the files (pack again from a good copy), and lists them and goes on with --allow-damaged. The result stays in RomFS.img.formats beside the image until the image changes (Ocarina of Time: 102,185 .zs files, 16 s cold from a USB SSD; none damaged in this repository's copy). - In place of PR seedds#1530's run-time substitution, which served other textures for the damaged ones: the host serves a game's files as they are. - Reference entry in packing.md, symptom index, Ocarina of Time note. Unit test; check_formats run on Ocarina of Time's image and on a synthetic damaged one. No game run.
…td stream is served as a profile-named substitute, ending a background reload loop (CPU 412% → 180% on the Mac) Upstream pull requests applied in this commit (their authors' work, brought onto this tree with a three-way merge; the description is in each PR): - seedds#1530 by aksmith-git (closed): Ocarina of Time: a RomFS .zs file that is not a zstd stream is served as a profile-named substitute, ending a background reload loop (CPU 412% → 180% on the Mac)
…textures The NSP script's check stopped a player's build on the same three .zs files as the contributor's NUP (PR seedds#1530), two with 12,288 leading zero bytes and the Water Temple gate with 8,192: one damaged release in circulation, it seems, rather than one bad download. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…textures The NSP script's check stopped a player's build on the same three .zs files as the contributor's NUP (PR seedds#1530), two with 12,288 leading zero bytes and the Water Temple gate with 8,192: one damaged release in circulation, it seems, rather than one bad download. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…textures The NSP script's check stopped a player's build on the same three .zs files as the contributor's NUP (PR seedds#1530), two with 12,288 leading zero bytes and the Water Temple gate with 8,192: one damaged release in circulation, it seems, rather than one bad download. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
In Ocarina of Time (Switch 2,
0400486024DEC000, update v131072) the game's background model loader never went idle: theOptimizeChangeBancthread used about one core and aParallelDecompThreadabout 0.75 core for the whole session, the process at about 400% CPU on the Mac. The cause is a RomFS texture that cannot be decompressed in the dump we have. This PR has the host serve such a file as a substitute the profile names, and the Ocarina of Time profile names one for each of the three files affected.Cause
DM_FS=1,Model/Land_FairyFountain_Base_A.Land_FairyFountain_Base_A_01.bfres.zs(2.4 MB) andTex/CmnTex_Map_Soil_FairyFountain_Floor_D_Nrm.bntx.zswere each opened 2,095 times in about 95 s (about 22 a second). Every other file was opened 12 times or fewer..zsfiles in the RomFS found two more like it:Tex/Rock_WaterTemple_Gate_M_01_Nrm.bntx.zsandTex/RBake_Scene_GanonStage_G_2_1_d0_t0.bntx.zs.OptimizeChangeBanc(main+0xf7a0) loops over the area's 852 entries and goes back to its 16 ms sleep only after a pass in which every entry is done. Probes showed one entry that never finished, the Kokiri Forest fairy fountain model (Land_FairyFountain…). The game requested it again on every pass, andParallelDecompThreaddecompressed the 2.4 MB model each time..bntx, which isn't there either, and still fails the model (1,706 reloads in a test run).Fix
hle_fs.cimg_servereads the first 4 bytes of a RomFS image file named*.zsonce per entry, at its firstOpenFileorGetEntryType, and records the result in memory. If the file starts with neither a zstd frame nor a skippable frame:romfs_substitute, which takes<path>=<substitute path>pairs (DM_ROMFS_SUBSTreplaces the list);[RED]line names the file.DM_ROMFS_ZSTD_CHECK=0serves such files as stored. Every other file is served exactly as before, including every file in a copy without the damage.Ocarina of Time profile:
Tex/Dummy_Flat_Normal_CmnTex_Chara_DetailMap_Nrm.bntx.zs;..._G_2_2_d0_t0(not checked in game).All three substitutes are already in the RomFS, so an existing
RomFS.imgworks as it is.Second commit: a small diagnostic used to find this.
DM_PROBE_EVERY=Ncounts every probe hit and prints every N-th one, so a probe's#gives a hit rate without printing a line per hit.Docs:
docs/reference/packing.md, under Damaged packages, and the symptom index regenerated;dm/games/README.md;docs/env_switches.tsv;Measurements
Mac (M4 Pro), 5-minute runs in Kokiri Forest, medians of the windows from frame 5000:
OptimizeChangeBanc/ParallelDecompThreadThe model and its texture are now opened once each. Screenshots of the village and the Saria scene match the runs before the change. The loop also ran on an iPad, where
OptimizeChangeBanctook about the same CPU time as on the Mac. This PR's branch has not been run on an iPad.Tests
make -C dm/host GAME=0400486024DEC000 -j6 dmhostbuilds.dm/host/tests/build/t_fs: 148 checks, 0 failed. The new checks cover:.zsfile of zeros is "not found" by entry type and by open, and is checked only once;python3 -m unittestpasses fortest_docs,test_env_switchesandtest_game_profile, anddocs_symptoms.py --checkreports the index is current.